home *** CD-ROM | disk | FTP | other *** search
/ Collection of Internet / Collection of Internet.iso / msdos / lynx / source / www / library / implemen / htaaprot.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-25  |  7.7 KB  |  227 lines

  1. /*                                   PROTECTION SETUP FILE
  2.                                              
  3.  */
  4.  
  5. #ifndef HTAAPROT_H
  6. #define HTAAPROT_H
  7.  
  8. #include "HTUtils.h"
  9. #include "HTGroup.h"
  10. #include "HTAssoc.h"
  11.  
  12. #ifdef SHORT_NAMES
  13. #define HTAAgUid        HTAA_getUid
  14. #define HTAAgGid        HTAA_getGid
  15. #define HTAAgDPr        HTAA_setDefaultProtection
  16. #define HTAAsCPr        HTAA_setCurrentProtection
  17. #define HTAAgCPr        HTAA_getCurrentProtection
  18. #define HTAAgDPr        HTAA_getDefaultProtection
  19. #define HTAAclPr        HTAA_clearProtections
  20. #endif /*SHORT_NAMES*/
  21. /*
  22.  
  23. Server's Representation of Document (Tree) Protections
  24.  
  25.  */
  26.  
  27. typedef struct {
  28.     char *        template;     /* Template for this protection         */
  29.     char *        filename;     /* Current document file                */
  30.     char *        uid_name;     /* Effective uid (name of it)           */
  31.     char *        gid_name;     /* Effective gid (name of it)           */
  32.     GroupDef *    mask_group;   /* Allowed users and IP addresses       */
  33.     HTList *      valid_schemes;/* Valid authentication schemes         */
  34.     HTAssocList * values;       /* Association list for scheme specific */
  35.                                 /* parameters.                          */
  36. } HTAAProt;
  37. /*
  38.  
  39. Callbacks for rule system
  40.  
  41.    The following three functioncs are called by the rule system:
  42.    
  43.       HTAA_clearProtections() when starting to translate a filename
  44.       
  45.       HTAA_setDefaultProtection() when "defprot" rule is matched
  46.       
  47.       HTAA_setCurrentProtection() when "protect" rule is matched
  48.       
  49.    Protection setup files are cached by these functions.
  50.    
  51.  */
  52.  
  53. /* PUBLIC                                       HTAA_setDefaultProtection()
  54. **              SET THE DEFAULT PROTECTION MODE
  55. **              (called by rule system when a
  56. **              "defprot" rule is matched)
  57. ** ON ENTRY:
  58. **      cur_docname     is the current result of rule translations.
  59. **      prot_filename   is the protection setup file (second argument
  60. **                      for "defprot" rule, optional)
  61. **      eff_ids         contains user and group names separated by
  62. **                      a dot, corresponding to the effective uid
  63. **                      gid under which the server should run,
  64. **                      default is "nobody.nogroup" (third argument
  65. **                      for "defprot" rule, optional; can be given
  66. **                      only if protection setup file is also given).
  67. **
  68. ** ON EXIT:
  69. **      returns         nothing.
  70. **                      Sets the module-wide variable default_prot.
  71. */
  72. PUBLIC void HTAA_setDefaultProtection PARAMS((CONST char *      cur_docname,
  73.                                               CONST char *      prot_filename,
  74.                                               CONST char *      eff_ids));
  75.  
  76.  
  77.  
  78. /* PUBLIC                                       HTAA_setCurrentProtection()
  79. **              SET THE CURRENT PROTECTION MODE
  80. **              (called by rule system when a
  81. **              "protect" rule is matched)
  82. ** ON ENTRY:
  83. **      cur_docname     is the current result of rule translations.
  84. **      prot_filename   is the protection setup file (second argument
  85. **                      for "protect" rule, optional)
  86. **      eff_ids         contains user and group names separated by
  87. **                      a dot, corresponding to the effective uid
  88. **                      gid under which the server should run,
  89. **                      default is "nobody.nogroup" (third argument
  90. **                      for "protect" rule, optional; can be given
  91. **                      only if protection setup file is also given).
  92. **
  93. ** ON EXIT:
  94. **      returns         nothing.
  95. **                      Sets the module-wide variable current_prot.
  96. */
  97. PUBLIC void HTAA_setCurrentProtection PARAMS((CONST char *      cur_docname,
  98.                                               CONST char *      prot_filename,
  99.                                               CONST char *      eff_ids));
  100.  
  101.  
  102. /* SERVER INTERNAL                                      HTAA_clearProtections()
  103. **              CLEAR DOCUMENT PROTECTION MODE
  104. **              (ALSO DEFAULT PROTECTION)
  105. **              (called by the rule system)
  106. ** ON ENTRY:
  107. **      No arguments.
  108. **
  109. ** ON EXIT:
  110. **      returns nothing.
  111. **              Frees the memory used by protection information.
  112. */
  113. PUBLIC void HTAA_clearProtections NOPARAMS;
  114. /*
  115.  
  116. Getting Protection Settings
  117.  
  118.       HTAA_getCurrentProtection() returns the current protection mode (if there was a
  119.       "protect" rule). NULL, if no "protect" rule has been matched.
  120.       
  121.       HTAA_getDefaultProtection() sets the current protection mode to what it was set to
  122.       by "defprot" rule and also returns it (therefore after this call also
  123.       HTAA_getCurrentProtection() returns the same structure.
  124.       
  125.  */
  126.  
  127. /* PUBLIC                                       HTAA_getCurrentProtection()
  128. **              GET CURRENT PROTECTION SETUP STRUCTURE
  129. **              (this is set up by callbacks made from
  130. **               the rule system when matching "protect"
  131. **               (and "defprot") rules)
  132. ** ON ENTRY:
  133. **      HTTranslate() must have been called before calling
  134. **      this function.
  135. **
  136. ** ON EXIT:
  137. **      returns a HTAAProt structure representing the
  138. **              protection setup of the HTTranslate()'d file.
  139. **              This must not be free()'d.
  140. */
  141. PUBLIC HTAAProt *HTAA_getCurrentProtection NOPARAMS;
  142.  
  143.  
  144.  
  145. /* PUBLIC                                       HTAA_getDefaultProtection()
  146. **              GET DEFAULT PROTECTION SETUP STRUCTURE
  147. **              (this is set up by callbacks made from
  148. **               the rule system when matching "defprot"
  149. **               rules)
  150. ** ON ENTRY:
  151. **      HTTranslate() must have been called before calling
  152. **      this function.
  153. **
  154. ** ON EXIT:
  155. **      returns a HTAAProt structure representing the
  156. **              default protection setup of the HTTranslate()'d
  157. **              file (if HTAA_getCurrentProtection() returned
  158. **              NULL, i.e. if there is no "protect" rule
  159. **              but ACL exists, and we need to know default
  160. **              protection settings).
  161. **              This must not be free()'d.
  162. */
  163. PUBLIC HTAAProt *HTAA_getDefaultProtection NOPARAMS;
  164. /*
  165.  
  166. Get User and Group IDs to Which Set to
  167.  
  168.  */
  169.  
  170. #ifndef VMS
  171. /* PUBLIC                                                       HTAA_getUid()
  172. **              GET THE USER ID TO CHANGE THE PROCESS UID TO
  173. ** ON ENTRY:
  174. **      No arguments.
  175. **
  176. ** ON EXIT:
  177. **      returns the uid number to give to setuid() system call.
  178. **              Default is 65534 (nobody).
  179. */
  180. PUBLIC int HTAA_getUid NOPARAMS;
  181.  
  182.  
  183. /* PUBLIC                                                       HTAA_getGid()
  184. **              GET THE GROUP ID TO CHANGE THE PROCESS GID TO
  185. ** ON ENTRY:
  186. **      No arguments.
  187. **
  188. ** ON EXIT:
  189. **      returns the uid number to give to setgid() system call.
  190. **              Default is 65534 (nogroup).
  191. */
  192. PUBLIC int HTAA_getGid NOPARAMS;
  193. #endif /* not VMS */
  194. /*
  195.  
  196.    For VMS:
  197.  
  198.  */
  199.  
  200. #ifdef VMS
  201. /* PUBLIC                                                       HTAA_getUidName()
  202. **              GET THE USER ID NAME (VMS ONLY)
  203. ** ON ENTRY:
  204. **      No arguments.
  205. **
  206. ** ON EXIT:
  207. **      returns the user name
  208. **              Default is "" (nobody).
  209. */
  210. PUBLIC char * HTAA_getUidName NOPARAMS;
  211.  
  212. /* PUBLIC                                                       HTAA_getFileName
  213. **              GET THE FILENAME (VMS ONLY)
  214. ** ON ENTRY:
  215. **      No arguments.
  216. **
  217. ** ON EXIT:
  218. **      returns the filename
  219. */
  220. PUBLIC char * HTAA_getFileName NOPARAMS;
  221. #endif /* VMS */
  222.  
  223. #endif /* not HTAAPROT_H */
  224. /*
  225.  
  226.    End of file HTAAProt.h.  */
  227.